package com.example.xunai.dto.request.ai;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class StreamChatRequest {
    @NotBlank(message = "消息内容不能为空")
    private String message;

    @NotBlank(message = "会话ID不能为空")
    private String sessionId;

    private Long conversationId;

    @NotNull(message = "用户ID不能为空")
    private Long userId;

    @NotBlank(message = "模型类型不能为空")
    private String modelType;

    private String requestId;

    public static StreamChatRequest of(String message, String sessionId, Long conversationId,
                                       Long userId, String modelType) {
        return new StreamChatRequest(message, sessionId, conversationId, userId, modelType, null);
    }

    public static StreamChatRequest of(String message, String sessionId, Long conversationId,
                                       Long userId, String modelType, String requestId) {
        return new StreamChatRequest(message, sessionId, conversationId, userId, modelType, requestId);
    }

    public boolean isValid() {
        return message != null && !message.trim().isEmpty()
                && sessionId != null && !sessionId.trim().isEmpty()
                && userId != null && modelType != null && !modelType.trim().isEmpty();
    }
}